//============================================================================================
/**
 * @file	phclink_error.c
 * @brief	ＰＨＣ−ＤＳ接続画面 エラー時 【シーケンス】
 * @author	Akito Mori
 * @date	09.02.02
 */
//============================================================================================
#include "common.h"
#include "gflib/touchpanel.h"
#include "system/gamedata.h"
#include "system/procsys.h"
#include "system/main.h"
#include "system/fontproc.h"
#include "system/window.h"
#include "system/pmfprint.h"
#include "system/snd_tool.h"
#include "system/arc_tool.h"
#include "system/arc_util.h"
#include "system/clact_tool.h"
#include "system/clact_util.h"
#include "system/msgdata.h"
#include "system/wordset.h"
#include "system/mystatus.h"
#include "system/wipe.h"
#include "savedata/config.h"
#include "itemtool/item.h"
#include "itemtool/myitem.h"
#include "msgdata/msg.naix"
#include "msgdata/msg_phc_com.h"

#include "application/phclink.h"
#include "phclink_obj_def.h"
#include "phclink_bmp_def.h"
#include "phclink_local.h"
#include "phclink_obj.h"
#include "phclink_bmp.h"
#include "phc_ds.naix"

enum{
	SUBSEQ_ERROR_MSG=0,
	SUBSEQ_ERROR_WAIT,
	SUBSEQ_ERROR_KEY_WAIT,
	SUBSEQ_ERROR_END,
	SUBSEQ_ERROR_MAX,
};


static int SubSeqErrorEnd( PHCLINK_WORK *wk );
static int SubSeqErrorKeyWait( PHCLINK_WORK *wk );
static int SubSeqErrorWait( PHCLINK_WORK *wk );
static int SubSeqErrorMsg( PHCLINK_WORK *wk );

static int (*SubSeqFuncTbl[])( PHCLINK_WORK *wk )={
	SubSeqErrorMsg,
	SubSeqErrorWait,
	SubSeqErrorKeyWait,
	SubSeqErrorEnd,
};



//==============================================================================
/**
 * @brief   エラー画面初期化（未使用）
 *
 * @param   wk
 *
 * @retval
 */
//==============================================================================
int PhcLink_SeqError_Init( PHCLINK_WORK *wk )
{
	OS_Printf("PhcLink_SeqError_Init\n");

	// フェードイン開始
	WIPE_SYS_Start(
		WIPE_PATTERN_WMS, WIPE_TYPE_FADEIN, WIPE_TYPE_FADEIN,
		WIPE_FADE_BLACK, WIPE_DEF_DIV, WIPE_DEF_SYNC, HEAPID_PHC_LINK );


	return SEQ_MAINSEQ_MAIN;
}

//==============================================================================
/**
 * @brief   エラー画面メイン（未使用）
 *
 * @param   wk
 *
 * @retval  int
 */
//==============================================================================
int PhcLink_SeqError_Main( PHCLINK_WORK *wk )
{

	OS_Printf("PhcLink_SeqError_Main\n");
	wk->subseq = SubSeqFuncTbl[wk->subseq]( wk );
	if(wk->subseq == SUBSEQ_ERROR_MAX){
		wk->mainseq_next = MAINSEQ_END_PHC;
		wk->subseq  = 0;
		return SEQ_MAINSEQ_END;
	}
	return SEQ_MAINSEQ_MAIN;
}
//==============================================================================
/**
 * @brief   エラー画面終了（未使用）
 *
 * @param   wk
 *
 * @retval  int
 */
//==============================================================================
int PhcLink_SeqError_End( PHCLINK_WORK *wk )
{
	OS_Printf("PhcLink_SeqError_End\n");
	return SEQ_MAINSEQ_INIT;
}



// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

static int SubSeqErrorMsg( PHCLINK_WORK *wk )
{
	wk->MsgIndex = PhcLinkBmp_TalkWinPrint( wk, PL_BMP_B_TALK, phc_box_error );

	return  SUBSEQ_ERROR_WAIT;
}
static int SubSeqErrorWait( PHCLINK_WORK *wk )
{
	if(GF_MSG_PrintEndCheck( wk->MsgIndex )==0){
		return SUBSEQ_ERROR_KEY_WAIT;
	}
	return SUBSEQ_ERROR_WAIT;
}
static int SubSeqErrorKeyWait( PHCLINK_WORK *wk )
{
	if(sys.trg&PAD_BUTTON_DECIDE || sys.tp_trg){
		return SUBSEQ_ERROR_END;
	}
	return SUBSEQ_ERROR_KEY_WAIT;
}


static int SubSeqErrorEnd( PHCLINK_WORK *wk )
{
	return SUBSEQ_ERROR_MAX;
}